﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Globalization;
using AqueleAjax.UI;

namespace AqueleAjax.UI.Controls
{
    public class AutoCompleteResultItemCollection : ICollection<AutoCompleteResultItem>, IEnumerable<AutoCompleteResultItem>
    {
        private List<AutoCompleteResultItem> _items;

        private List<AutoCompleteResultItem> Items
        {
            get
            {
                if (this._items == null)
                {
                    this._items = new List<AutoCompleteResultItem>();
                }

                return _items; 
            }
            set
            {
                this._items = value;
            }
        }

        public void Add(AutoCompleteResultItem item)
        {
            this.Items.Add(item);
        }

        public void Clear()
        {
            this.Items.Clear();
        }

        public bool Contains(AutoCompleteResultItem item)
        {
            return this.Items.Contains(item);
        }

        public void CopyTo(AutoCompleteResultItem[] array, int arrayIndex)
        {
            this.Items.CopyTo(array, arrayIndex);
        }

        public int Count
        {
            get { return this.Items.Count; }
        }

        public bool IsReadOnly
        {
            get { return false; }
        }

        public bool Remove(AutoCompleteResultItem item)
        {
            return this.Items.Remove(item);
        }

        public IEnumerator<AutoCompleteResultItem> GetEnumerator()
        {
            return this.Items.GetEnumerator();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return this.Items.GetEnumerator();
        }

        IEnumerator<AutoCompleteResultItem> IEnumerable<AutoCompleteResultItem>.GetEnumerator()
        {
            return this.Items.GetEnumerator();
        }
    }
}
